package bTree.LeetCode;

public class 删除有序数组中的重复项2 {
    public int removeDuplicates(int[] nums) {
        int left=1,right=1,temp=1,n= nums.length;
        while (right< n){
            if(nums[right]==nums[right-1]&&temp<2){
                nums[left++]=nums[right];
                temp++;
                right++;
            }
            else if(nums[right]==nums[right-1]&&temp>=2){
                temp++;
                right++;
            }
            else if(nums[right]!=nums[right-1]){
                nums[left++]=nums[right];
                temp=1;
                right++;
            }
        }
        return left;
    }
}
